package com.example.champtionthree.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.champtionthree.R;
import com.example.champtionthree.bean.ExamInfo;

import java.util.ArrayList;

public class FirstChildAdapter extends RecyclerView.Adapter<FirstChildAdapter.ViewHolder> {
    private  ArrayList<ExamInfo.SmallItemInfo> value;
    private Context mContext;

    public FirstChildAdapter(ArrayList<ExamInfo.SmallItemInfo> value, Context mContext) {
        this.value = value;
        this.mContext = mContext;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.first_layou_list,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        ExamInfo.SmallItemInfo smallItemInfo = value.get(position);
        Glide.with(mContext).load(smallItemInfo.image_url).into(holder.imageView);

    }

    @Override
    public int getItemCount() {
        return value.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);

           imageView = itemView.findViewById(R.id.iv_image);
        }
    }
}
